<?php

namespace App\Admin\Controllers;

use App\Models\ExhibitorInformation;
use App\Models\ExhibitorMessageTask;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class ExhibitorMessageTaskController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = '首页提示任务';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new ExhibitorMessageTask());

        $grid->column('contents', __('exhibitor_message_task.contents'));
        $grid->column('type_id', __('exhibitor_message_task.type_id'))->using(__('exhibitor_message_task.type_array'));
        $grid->actions(function ($actions) {

            //显示按钮、查看按钮
            $actions->disableView();
        });
        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(ExhibitorMessageTask::findOrFail($id));

        $show->field('id', __('Id'));
        $show->field('contents', __('Contents'));
        $show->field('exhibitor_message_id', __('Exhibitor message id'));
        $show->field('type_id', __('Type id'));

        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new ExhibitorMessageTask());
        $form->select('type_id', __('exhibitor_message_task.type_id'))->options(__('exhibitor_message_task.type_array'))->rules('required');

        $form->text('contents', __('exhibitor_message_task.contents'));
        $form->tools(function ($tools) {


            // 去掉`查看`按钮
            $tools->disableView();

        });
        $form->footer(function ($footer) {


            // 去掉`查看`checkbox
            $footer->disableViewCheck();


        });
        $form->saving(function (Form $form) {
            $form->model()->exhibitor_message_id = 1;


        });
        return $form;
    }
}
